use solutiont1::primes::composites;

pub fn goldbach_conjecture() -> u64 {
    let mut composites = composites().with_limit(10000);
    let mut nums = Vec::new();
    while let Some(n) = composites.next() {
        if n % 2 == 0 {
            continue;
        }
        if (1_u64..)
            .map(|i| 2 * i * i)
            .take_while(|&i| i < n)
            .all(|i| !composites.is_prime(n - i))
        {
            nums.push(n);
            if nums.len() == 2 {
                return nums.into_iter().sum();
            }
        }
    }
    unreachable!()
}
